package strangeattractor.core;

public class StrangePoint {
	// GENERAL NOTES
	// Each strange point can be calculated from the previous point.
	// A strange point will be plotted after calculating its next point,
	// And only if it is not an endpoint. The color is calculated
	// from two gradients: the first color is picked from the v-gradient,
	// which depends on the distance between the current and previous
	// point. The second is given by the angle of the three points.
	//
	//The screen is rendered as pixel/depth pairs, so that closer points
	//overwrite further points, but not the other way around.
	public DPoint point = new DPoint(0, 0, 0), prev = null, next = null;

	public StrangePoint(double x, double y, double z) {
		point.x = x;
		point.y = y;
		point.z = z;
	}
	
	public StrangePoint(StrangePoint previous, DPoint newP){
		this.point = newP;
		this.prev = previous.point;
		previous.next = this.point;
	}
	
	public double getDistance(){
		return point.getDistance(prev);
	}
	public double getAngle(){
		double a = point.getDistance(prev);
		double b = point.getDistance(next);
		double c = prev.getDistance(next);
		return Math.acos(0.5*(a/b + b/a) - c/(a*b));
	}

}
